package net.googlecode.demenkov.utils;

import net.googlecode.demenkov.domains.Message;

import java.util.Comparator;

/**
 * Comporator that compare messages by date and time
 *
 * @author Demenkov Yura
 */
public class MessageComporatorByDate implements Comparator<Message> {
    @Override
    public int compare(Message o1, Message o2) {
        return (int) ((o2.getDate().getTime() + o2.getTime().getTime()) - (o1.getDate().getTime() + o1.getTime().getTime()));
    }
}
